home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Common Stuff.h
-
- Contains: a simple include file that holds a number of standard functions,constants, and
- debugging macros. Anything that isn't likely to change from program to program.
-
- Written by:
-
- Copyright: Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 7/2/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
-
- #ifndef _COMMONSTUFF_
- #define _COMMONSTUFF_
-
- #pragma once
-
- /*********************************************************************************
- DEBUGGING and ERROR HANDLING MACROS
-
- These macros should be used to create code with proper error handling. In
- the debugging version of the macros, they dump a string to the debugger before
- dropping into the error handler.
-
- To turn debugging off, set the macro qDebugging to 0 before including Common Stuff.
-
- If an application wants to include special debugging code, the proper way to do this
- is with something like:
-
- #if qDebugging
- // do additional sanity checking here.
- #endif
-
- Note that this should only be additional sanity checking code and not eliminate all error
- checking code.
-
- *********************************************************************************/
- #define qDebugging 0
- #ifndef qDebugging
- #define qDebugging 0
- #endif
-
- #if qDebugging
- #define SIGNAL_ERROR(msg) {DebugStr(msg); goto error;}
- #else
- #define SIGNAL_ERROR(msg) {goto error;}
- #endif
-
- #define FAIL_NIL(y,msg) if (y == NULL) SIGNAL_ERROR(msg)
- #define FAIL_OSERR(y,msg) if (y != noErr) SIGNAL_ERROR(msg)
- #define FAIL_FALSE(y,msg) if (!y) SIGNAL_ERROR(msg)
-
-
- /*********************************************************************************
- QUICKDRAW
-
- This includes a standard set of functions and color constants to use in apps
- that use quickdraw. As written, this will only compile for C++, although the
- functions could be recast as macros.
-
- *********************************************************************************/
-
- #include <Quickdraw.h>
-
- const RGBColor kWhite = {0xFFFF, 0xFFFF, 0xFFFF};
- const RGBColor kBlack = {0x0000, 0x0000, 0x0000};
- const RGBColor kDarkBlue = {0x0000,0x0000,0x7000};
- const RGBColor kLtGrey = {0xC000,0xC000,0xC000};
- const RGBColor kMediumGrey = {0x7FFF,0x7FFF,0x7FFF};
-
- inline short RectWidth (const Rect& r) {
- return (r.right-r.left);
- }
-
- inline short RectHeight (const Rect& r) {
- return (r.bottom - r.top);
- }
-
- #endif /* _COMMONSTUFF_ */
-
-
-
-